unit con_operador;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls,dbtables,db;

type
  TFrmcon_operador = class(TFrmConsulta)
    Label2: TLabel;
    Edt_NomeOpe: TEdit;
    DbgGrid: TDBGrid;
    procedure BtnFecharClick(Sender: TObject);
    procedure Edt_NomeOpeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    codigo_ope :string;
    procedure FazConsulta;
  end;

var
  Frmcon_operador: TFrmcon_operador;

implementation

uses clsOperador,dm,biblio;

var Operador: TOperador;
    tq      : TQuery;
    tds     : TDataSource;

{$R *.DFM}

{ TFrmConsulta1 }

procedure TFrmcon_operador.FazConsulta;
begin
 if Edt_NomeOpe.text='' then Edt_NomeOpe.text := ' ';
 Operador.Consultar(Edt_NomeOpe.text,tq);
 tq.open;
 DbgGrid.Refresh;
end;

procedure TFrmcon_operador.BtnFecharClick(Sender: TObject);
begin
 codigo_ope:= tq.fieldbyname('codigo_ope').asstring;
 inherited;
end;

procedure TFrmcon_operador.Edt_NomeOpeKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
 if key=12 then begin
  FazConsulta;
  Edt_NomeOpe.SetFocus;
 end;
end;

procedure TFrmcon_operador.FormCreate(Sender: TObject);
begin
  inherited;
 Operador:= TOperador.create;
 tq      := TQuery.create(self);
 tds     := TDataSource.Create(self);
end;

procedure TFrmcon_operador.FormActivate(Sender: TObject);
begin
  inherited;
 tq.DatabaseName   := DmInt.Db.DatabaseName;
 tq.Active         := false;
 tds.DataSet       := tq;
 DbgGrid.DataSource:= tds;
 FazConsulta;
 Edt_NomeOpe.SetFocus;
end;

procedure TFrmcon_operador.FormDestroy(Sender: TObject);
begin
  inherited;
 Operador.free;
 tq.close;
 tq.free;
 tds.free;
end;

end.
